package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FaceSetInfo;
import com.ruoyi.system.service.IFaceSetInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统人脸库Controller
 * 
 * @author ruoyi
 * @date 2025-05-05
 */
@RestController
@RequestMapping("/system/FaceSetInfo")
public class FaceSetInfoController extends BaseController
{
    @Autowired
    private IFaceSetInfoService faceSetInfoService;

    /**
     * 查询系统人脸库列表
     */
    @PreAuthorize("@ss.hasPermi('system:FaceSetInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaceSetInfo faceSetInfo)
    {
        startPage();
        List<FaceSetInfo> list = faceSetInfoService.selectFaceSetInfoList(faceSetInfo);
        return getDataTable(list);
    }

    /**
     * 导出系统人脸库列表
     */
    @PreAuthorize("@ss.hasPermi('system:FaceSetInfo:export')")
    @Log(title = "系统人脸库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FaceSetInfo faceSetInfo)
    {
        List<FaceSetInfo> list = faceSetInfoService.selectFaceSetInfoList(faceSetInfo);
        ExcelUtil<FaceSetInfo> util = new ExcelUtil<FaceSetInfo>(FaceSetInfo.class);
        util.exportExcel(response, list, "系统人脸库数据");
    }

    /**
     * 获取系统人脸库详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:FaceSetInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(faceSetInfoService.selectFaceSetInfoById(id));
    }

    /**
     * 新增系统人脸库
     */
    @PreAuthorize("@ss.hasPermi('system:FaceSetInfo:add')")
    @Log(title = "系统人脸库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaceSetInfo faceSetInfo)
    {
        return toAjax(faceSetInfoService.insertFaceSetInfo(faceSetInfo));
    }

    /**
     * 修改系统人脸库
     */
    @PreAuthorize("@ss.hasPermi('system:FaceSetInfo:edit')")
    @Log(title = "系统人脸库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaceSetInfo faceSetInfo)
    {
        return toAjax(faceSetInfoService.updateFaceSetInfo(faceSetInfo));
    }

    /**
     * 删除系统人脸库
     */
    @PreAuthorize("@ss.hasPermi('system:FaceSetInfo:remove')")
    @Log(title = "系统人脸库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(faceSetInfoService.deleteFaceSetInfoByIds(ids));
    }

    /**
     * 删除huawei sdk人脸库
     */
	@PostMapping("/{faceSetName}")
    public AjaxResult removeFaceSetFace(@PathVariable String faceSetName)
    {
        return success(faceSetInfoService.removeFaceSetFace(faceSetName));
    }
    /**
     * 查询huawei sdk人脸库
     */
	@GetMapping("/getFaceSetFace")
    public AjaxResult getFaceSetFace(String faceSetName)
    {
        return success(faceSetInfoService.getFaceSetFace(faceSetName));
    }
}
